//
//  LikeOfCustom.m
//  PetAPP
//
//  Created by apple on 16/3/7.
//  Copyright © 2016年 Yuming. All rights reserved.
//

#import "LikeOfCustom.h"
#import <DKNightVersion.h>

#define WIDTH self.frame.size.width
#define HEIGHT self.frame.size.height

@implementation LikeOfCustom

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.center.x - ( HEIGHT / 5 * 3 - 10) / 2, 0,  HEIGHT / 5 * 3 - 10, HEIGHT / 5 * 3 - 10)];
    [self addSubview:imageView];
    [imageView release];
    imageView.image = [UIImage imageNamed:@"zhanweitu"];
    imageView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapAction)];
    [imageView addGestureRecognizer:tap];
    [tap release];
    
    
    UILabel *labelOfText = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(imageView.frame) + 10, WIDTH, HEIGHT / 5 - 10)];
    [self addSubview:labelOfText];
    [labelOfText release];
    labelOfText.text = @"只有登录后才能查看好友动态哦!";
    labelOfText.textAlignment = NSTextAlignmentCenter;
    labelOfText.textColor = [UIColor colorWithRed:0.7212 green:0.7212 blue:0.7212 alpha:1.0];
    
    
    UIButton *buttonOfLogin = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:buttonOfLogin];
    [buttonOfLogin release];
    buttonOfLogin.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:255/256.0 green:207/256.0 blue:87/256.0 alpha:1], [UIColor grayColor]);
    [buttonOfLogin dk_setTitleColorPicker:DKColorWithColors([UIColor brownColor], [UIColor whiteColor]) forState:UIControlStateNormal];
    [buttonOfLogin setTitle:@"登录/注册" forState:UIControlStateNormal];
    buttonOfLogin.frame = CGRectMake(self.center.x -  WIDTH / 3 / 2 - 10, CGRectGetMaxY(labelOfText.frame) + 10, WIDTH / 3 + 20,  HEIGHT / 5 - 20);
    buttonOfLogin.layer.cornerRadius = 5;

    [buttonOfLogin addTarget:self action:@selector(handleButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)handleButtonAction:(UIButton *)button {
    [self handleTapAction];
    
}

- (void)handleTapAction {
    [[NSNotificationCenter defaultCenter] postNotificationName:@"PushLoginVC" object:nil userInfo:nil];

}

@end
